{include file='public/_meta'}
<title>规则管理</title>
</head>
<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span> 规则管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <form class="Huiform" method="post" action="index.html" target="_self">
            <input type="text" class="input-text" style="width:250px" placeholder="规则名称" id="keywords" name="keywords">
            <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜一级规则节点</button>
        </form>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-bottom: 10px;">
      <span class="l">
          <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
          <a href="javascript:;" onclick="admin_auth_add('添加规则节点','add.html','370','410')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加规则节点</a>
      </span> <span class="r" style="padding-top: 8px;">共有数据：<strong>{$totalcounts}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-bg table-sort">
        <thead>
        <tr>
            <th scope="col" colspan="8">规则节点</th>
        </tr>
        <tr class="text-c">
            <th width="25"><input type="checkbox" name="" id="checkAll" value=""></th>
            <th width="40">ID</th>
            <th width="200">一级规则</th>
            <th width="200">二级规则</th>
            <th width="200">三级规则</th>
            <th>规则</th>
            <th width="70">是否菜单</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        {if $list}
        {foreach $list as $k=>$v}
        <tr class="text-c">
            <td><input type="checkbox" value="{$v.id}" name=""></td>
            <td>{$v.id}</td>
            <td>{$v.title}</td>
            <td>--</td>
            <td>--</td>
            <td>{$v.auth}</td>
            <td>{$v.is_menu}</td>
            <td>
                <a title="编辑规则" href="javascript:;" onclick="admin_auth_edit('编辑规则','<?php echo url('admin/auth/edit',['id'=>$v['id']]);?>','370','410')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="删除" href="javascript:;" onclick="admin_auth_del(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        {if $v.children}
        {foreach $v.children as $lk=>$lv}
        <tr class="text-c">
            <td><input type="checkbox" value="{$lv.id}" name="ckb-id"></td>
            <td>{$lv.id}</td>
            <td>--</td>
            <td>{$lv.title}</td>
            <td>--</td>
            <td>{$lv.auth}</td>
            <td>{$lv.is_menu}</td>
            <td>
                <a title="编辑规则" href="javascript:;" onclick="admin_auth_edit('编辑规则','<?php echo url('admin/auth/edit',['id'=>$lv['id']]);?>','370','410')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="删除" href="javascript:;" onclick="admin_auth_del(this,'{$lv.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        {if $lv.children}
        {foreach $lv.children as $lk1=>$lv1}
        <tr class="text-c">
            <td><input type="checkbox" value="{$lv1.id}" name="ckb-id"></td>
            <td>{$lv1.id}</td>
            <td>--</td>
            <td>--</td>
            <td>{$lv1.title}</td>
            <td>{$lv1.auth}</td>
            <td>{$lv1.is_menu}</td>
            <td>
                <a title="编辑规则" href="javascript:;" onclick="admin_auth_edit('编辑规则','<?php echo url('admin/auth/edit',['id'=>$lv1['id']]);?>','370','410')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="删除" href="javascript:;" onclick="admin_auth_del(this,'{$lv1.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        {/foreach}
        {/if}
        {/foreach}
        {/if}


        {/foreach}
        {/if}
        </tbody>
    </table>
</div>

<!--_footer 作为公共模版分离出去-->
{include file='public/_footer'}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__PUBLIC__lib/jquery.treetable.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.table-sort').dataTable({
            "aaSorting": [],//默认第几个排序
            "bStateSave": false,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0]}// 制定列不参与排序
            ]
        });
    });
    /*
        参数解释：
        title	标题
        url		请求的url
        id		需要操作的数据id
        w		弹出层宽度（缺省调默认值）
        h		弹出层高度（缺省调默认值）
    */
    /*管理员-规则-添加*/
    function admin_auth_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-规则-编辑*/
    function admin_auth_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*管理员-规则-删除*/
    function admin_auth_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.getJSON("delete.html",{'ids':id},function(res){
                if(parseInt(res.statusCode)==200){
                    $(obj).parents("tr").remove();
                    layer.msg(res.message,{icon:1,time:1000});
                    window.location.reload();
                }else{
                    layer.msg(res.message);
                }
            });
        });
    }

    function datadel(){
        var gid = '';
        layer.confirm('确定要执行该批量操作吗？',function(){
            $("input:checkbox").each(function(index){
                if($(this).is(':checked')==true){
                    var id = $(this).val();
                    if(id){
                        gid += id+','
                    }
                }
            });
            gid = gid.substring(0,gid.length-1);
            if(gid==''){
                layer.msg("请选择要操作的项");
            }else{
                // 由于需要JSON数据，所以使用$.getJSON
                $.getJSON("{:url('admin/auth/delete')}", { 'ids': gid }, function(res){
                    layer.msg(res.message,{icon:1,time:1000});
                    window.location.reload();
                });
            }
        });

    }
</script>
</body>
</html>